import http from '@/utils/http'
import { AppDispatch } from '..'

/**
 * 获取评论或评论回复
 * @param type   评论类型，a-对文章(article)的评论，c-对评论(comment)的回复
 * @param source 源id，文章id或评论id
 * @returns
 */
export const getComments = ({ type = 'a', source = '' }) => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get(`/v1_0/comments`, { params: { type, source } })
    console.log(`/v1_0/comments`, res)
    dispatch({ type: 'comment/saveComments', payload: res.data })
  }
}
